#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time    : 2021/4/19 下午2:25
# @Author  : fugang_le
# @Software: PyCharm


######################################### 装饰器的使用 #########################################
import functools
import time

def spend_time(func):
    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        start_time = time.time()
        result = func(*args, **kwargs)
        spend_time = str(round((time.time() - start_time) * 1000, 2))
        print("function " + func.__name__ + " speed time: {}ms".format(spend_time))
        return result
    return wrapper

    return wrapper

@spend_time
def a():
    for i in range(100):
        i += 1

def b():
    for i in range(1000):
        i += 1

# a()
